import type { RouteRecordRaw } from "vue-router";

const routes: RouteRecordRaw = {
    path: "/",
    redirect: () => {
        const isMobile =
            typeof window !== "undefined" &&
            window.matchMedia("(max-width: 450px)").matches;

        return isMobile ? "/mobile/introduction" : "/pc/introduction";
    },
    children: [
        {
            path: "pc",
            redirect: "/pc/introduction",
        },
        {
            path: "mobile",
            redirect: "/mobile/introduction",
        },
        {
            path: "mobile/introduction",
            name: "MobileIntroduction",
            component: () => import("@/views/mobile/AiIntroduction.vue"),
        },
        {
            path: "mobile/chat",
            name: "MobileChat",
            component: () => import("@/views/mobile/AiChat.vue"),
        },
        {
            path: "mobile/history",
            name: "MobileHistory",
            component: () => import("@/views/mobile/ConversationHistory.vue"),
        },
        {
            path: "pc/introduction",
            name: "PcIntroduction",
            component: () => import("@/views/pc/AiIntroduction.vue"),
        },
        {
            path: "pc/chat",
            name: "PcChat",
            component: () => import("@/views/pc/AiChat.vue"),
        },
    ],
};

export default routes;
